package com.lly.songhigh.fragment;

import android.support.v4.app.Fragment;
import android.util.SparseArray;

/**
 * Created by dllo on 15/10/22.
 */
public class DiscoverFragmentFactory {
    private static SparseArray<Fragment> fragmentArr = new SparseArray<>();
    public static Fragment creatFragment(int position) {
        Fragment f = fragmentArr.get(position);
        if (f == null) {
            switch (position) {
                case 0:
                    f = new ChartsFragment();
                    break;
                case 1:
                    f = new SongSheetFragment();
                    break;
                case 2:
                    f = new RadioStationFragment();
                    break;
                case 3:
                    f = new SingerFragment();
                    break;
                default:
                    f = new ChartsFragment();
                    break;
            }
            fragmentArr.put(position, f);
        }
        return f;
    }
}
